<?php

use Faker\Generator as Faker;
use Carbon\Carbon;

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/

$factory->define(App\Models\User::class, function (Faker $faker) {
    static $password;

    $addresses = [
        ["广东省", "汕头市", "金平区"],
        ["广东省", "汕头市", "龙湖区"],
        ["广东省", "汕头市", "澄海区"],
        ["广东省", "汕头市", "潮阳区"],
        ["广东省", "汕头市", "潮南区"],
        ["广东省", "汕头市", "南澳县"],
        ["广东省", "深圳市", "福田区"],
    ];
    $address   = $faker->randomElement($addresses);
    $phoneNumber=$faker->phoneNumber;
    $now = Carbon::now()->toDateTimeString();
    return [
        'name' => $phoneNumber,
        'password'          => $password ?: $password = bcrypt('password'),
        'nickname'          => $faker->name,
        'realname'          => $faker->name,
        'phone'             => $phoneNumber,
        'address'           => $address[0].$address[1].$address[2].sprintf('第%d街道第%d号', $faker->randomNumber(2), $faker->randomNumber(3)),
        'remember_token'    => str_random(10),
        'introduction'      => $faker->sentence(),
    ];
});
